<template>
    <div>
        <div class="uptitle">稿件审核</div>
        <div v-for="(item, index) in list" :key="index">
            <div v-if="item.sign === '待审核'" class="uptext">
                <div class="upbox">
                    <div class="upuid">投稿人:{{ item.uid }}</div>
                    <div class="updata">{{ item.time }}</div>
                </div>
                <div class="uptitles">{{ item.title }}</div>
                <div class="uptexts" v-html="item.content"></div>
                <el-button class="upbutton" @click="falseItem(item.eid)" type="danger">未通过</el-button>
                <el-button class="upbuttons" @click="trueItem(item.eid)">通过</el-button>
            </div>
        </div>
    </div>
</template>
  
<script>
export default {
    name: "three",
    data() {
        return {
            texts: [],
            list: [],
        };
    },
    methods: {
        //获取稿件信息
        gettextdata() {
            fetch(`http://localhost:3000/textdata`, {
                method: 'GET'
            })
                .then(res => res.text())
                .then(res => {
                    this.texts = res
                    this.list = JSON.parse(this.texts)
                    // console.log(this.list);
                });
        },
        //通过稿件申请
        trueItem(eid) {
            fetch(`http://localhost:3000/truesign/${eid}`, {
                method: "POST",
            }).then(() => {
                this.gettextdata();
            })
            this.$message.success('审核成功')
            // location.reload();
        },
        //不通过稿件申请
        falseItem(eid) {
            fetch(`http://localhost:3000/falsesign/${eid}`, {
                method: "POST",
            }).then(() => {
                this.gettextdata();
            })
            this.$message.success('审核成功')
            // location.reload();
        },
    },
    mounted() {
        this.gettextdata();
        // setInterval(() => {
        //     this.gettextdata();
        // }, 1000);
    },
};
</script>
<style>
.uptitle {
    width: 200px;
    height: 50px;
    font-size: 30px;
    font-weight: bold;
    color: black;
    margin-left: 1%;
    margin-top: 5%;
}

.uptext {
    width: 80%;
    height: auto;
    background-color: rgb(241, 241, 241);
    margin-bottom: 30px;
    margin-left: 150px;
}

.upuid {
    border-radius: 50%;
    width: 20%;
    height: auto;
    margin-left: 5%;
    margin-top: 2%;
    padding-top: 10px;
    padding-bottom: 7px;
    font-size: 18px;
}

.uptitles {
    width: 30%;
    height: 20px;
    margin-left: 10%;
    font-size: 18px;
}

.uptexts {
    width: 70%;
    height: auto;
    ;
    margin-left: 15%;
    margin-top: 2%;
    background-color: rgb(231, 230, 227);
    margin-bottom: 30px;
}

.updata {
    width: 30%;
    height: 20px;
    margin-right: 10px;
    margin-left: 5%;
}

.upbox {
    width: 100%;
    height: 80px;
}

.upbutton {
    margin-left: 70%;
}

.upbuttons {
    margin-left: 10%;
}

.uptexts img {
    max-width: 200px;
    height: auto;
}
</style>